<!DOCTYPE html>
<html lang="en">
{% extends 'app01/article_cellation.html' %}
{% block message %}
    <a href="{% url 'app01_message' %}" class="list-group-item">未读消息({{ count }})</a>
{% endblock %}
{% block person_manage %}
    <a class="navbar-brand" href="#">个人信息</a>
{% endblock %}

{% block all_li %}
    <li role="presentation" class="active">
        <a href="#home" aria-controls="home" role="tab" data-toggle="tab">未读消息</a></li>
    <li role="presentation" class="active">
        <a href="{% url 'app01_backend' %}" style="color: #337ab7">返回个人管理</a></li>

{% endblock %}

{% block all_content %}
    {% block suibi %}
        <div class="panel panel-default">
            <div class="panel-heading">用户发来信息</div>
            <div class="panel-body">
                {% for send in send_lis %}
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="img-circle" src="/media/{{ send.avatar }}" height="60" alt="...">
                            </a>
                        </div>
                        <div class="media-body">
                            <h4 class="media-heading">{{ send.username }}</h4>
                            <p> <a href="/app01/userwechat?pk={{ send.id }}"><span class="glyphicon glyphicon-eye-open"></span>点击查看</a>  </p>
                        </div>
                    </div>
                    {% empty %}
                    <h2>无新消息。</h2>
                {% endfor %}

            </div>
        </div>

    {% endblock %}

{% endblock %}
{% block js %}
    <script>
     //文件上传的ajax请求
        $("#up_btn_id").click(function () {
            let formObj = new FormData()
            formObj.append('file', $('#up_file_id')[0].files[0])
            formObj.append('filename', $('#file_name_id').val())
            formObj.append('desc', $('#file_desc_id').val())
            let radio_chioce = $('input[name="share"]:checked').val();
            formObj.append('share', radio_chioce)

            $.ajax({
                url: "/app01/upload_file/",
                type: 'post',
                data: formObj,
                contentType: false,
                processData: false,
                success: function (array) {
                    if (array.code === 1000) {
                        alert(array.msg0)
                        parent.location.href = array.url
                    } else if (array.code === 2000) {
                        //用户输入不正确的提示
                        $('#p1').next().text(array.msg1)
                        $('#p2').next().text(array.msg2)
                        $('#p3').next().text(array.msg3)
                    } else {
                        alert(array.msg0)
                    }

                }
            })


        });

    </script>
{% endblock %}